package com.ruibang.glass.purchase.controller;


import com.ruibang.glass.purchase.domain.req.PurchaseApplyReq;
import com.ruibang.glass.purchase.entity.PurchaseApplyManage;
import com.ruibang.glass.purchase.service.PurchaseApplyManageService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 供应商类别管理
 * @author mameng
 */
@Api(tags = "供应商类别管理")
@RestController
@RequestMapping("/api/glass/purchase/apply/management")
public class PurchaseApplyManagementController {


    @Autowired
    private PurchaseApplyManageService purchaseApplyManageService;

    @PostMapping("/list")
    @ApiOperation(value = "供应商列表", response = ResultBody.class)
    public ResultBody queryList(@RequestBody PurchaseApplyReq purchaseApplyReq) {
        return ResultBody.success(purchaseApplyManageService.queryApplyManageDTOList(purchaseApplyReq));
    }


    @PostMapping("addChild")
    @ApiOperation(value = "新增", response = ResultBody.class)
    public ResultBody addChild(@RequestBody PurchaseApplyManage areaManage) {
        purchaseApplyManageService.addChild(areaManage);
        return ResultBody.success();
    }


    @PostMapping("editChild")
    @ApiOperation(value = "名称跟新", response = ResultBody.class)
    public ResultBody editChild(@RequestBody PurchaseApplyManage areaManage) {
        purchaseApplyManageService.editChild(areaManage);
        return ResultBody.success();
    }


    @GetMapping("deleteAll/{id}")
    @ApiOperation(value = "删除类别", response = ResultBody.class)
    public ResultBody deleteAll(@PathVariable("id") String id) {
        purchaseApplyManageService.removePurchaseApplyManage(id);
        return ResultBody.success();
    }

    @GetMapping("getAreaNameList")
    @ApiOperation(value = "获取供应商名称", response = ResultBody.class)
    public ResultBody getAreaNameList() {
        return ResultBody.success(purchaseApplyManageService.getAreaNameList());
    }


}
